import { Element } from './element';

BI.Element = Element;
BI.Element.renderEngine = {
    createElement: (widget) => {
        // eslint-disable-next-line no-undef
        if (BI.isWidget(widget)) {
            var o = widget.options;
            if (o.element instanceof Element) {
                return o.element;
            }
            if (typeof o.element === 'string' && o.element !== 'body') {
                o.root = false;
                return new Element(widget);
            }

            if (o.root === true) {
                return new Element();
            }
        }
        // eslint-disable-next-line no-undef
        if (BI.isString(widget)) {
            return new Element(widget);
        }
        return new Element(widget);
    },

    createFragment() {
        return new Element();
    }
}
